package com.party.core.service.serviceguide.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.serviceguide.ServiceGuideTypeReadDao;
import com.party.core.dao.write.serviceguide.ServiceGuideTypeWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.serviceguide.ServiceGuideType;
import com.party.core.service.serviceguide.IServiceGuideTypeService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @program: party
 * @description: 服务指南类型业务接口实现
 * @author: Hua Qunhao
 * @create: 2019-04-17 09:25
 **/
@Service("ServiceGuideTypeService")
public class ServiceGuideTypeService implements IServiceGuideTypeService {
    @Autowired
    private ServiceGuideTypeReadDao serviceGuideTypeReadDao;

    @Autowired
    private ServiceGuideTypeWriteDao serviceGuideTypeWriteDao;

    @Override
    public String insert(ServiceGuideType serviceGuideType) {
        BaseModel.preInsert(serviceGuideType);
        boolean result = serviceGuideTypeWriteDao.insert(serviceGuideType);
        if (result) {
            return serviceGuideType.getId();
        }
        return null;
    }

    @Override
    public boolean update(ServiceGuideType serviceGuideType) {
        serviceGuideType.setUpdateDate(new Date());
        return serviceGuideTypeWriteDao.update(serviceGuideType);
    }

    @Override
    public boolean deleteLogic(String id) {
        return serviceGuideTypeWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        return serviceGuideTypeWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ServiceGuideType get(String id) {
        return serviceGuideTypeReadDao.get(id);
    }

    @Override
    public List<ServiceGuideType> listPage(ServiceGuideType serviceGuideType, Page page) {
        return serviceGuideTypeReadDao.listPage(serviceGuideType,page);
    }

    @Override
    public List<ServiceGuideType> list(ServiceGuideType serviceGuideType) {
        return serviceGuideTypeReadDao.listPage(serviceGuideType,null);
    }

    @Override
    public List<ServiceGuideType> batchList(Set<String> ids, ServiceGuideType serviceGuideType, Page page) {
        if (CollectionUtils.isEmpty(ids)){
            return Collections.EMPTY_LIST;
        }
        return serviceGuideTypeReadDao.batchList(ids, new HashedMap(), page);
    }
    @Override
    public ServiceGuideType findServiceGuideTypeByName(String name) {
        return serviceGuideTypeReadDao.findServiceGuideTypeByName(name);
    }

    @Override
    public List<ServiceGuideType> querySGRListbysgId(String sgId) {
        return serviceGuideTypeReadDao.querySGRListbysgId(sgId);
    }

    @Override
    public List<Map<String, Object>> queryGuideTypeListBymemberId(String memberId) {
        return serviceGuideTypeReadDao.queryGuideTypeListBymemberId(memberId);
    }
}
